#include"multi-thread-dispatcher.h"

void Multi_Thread_Dispatcher::run()
{
	cv::Mat frame;
	bool init_flag = false;
	init_modules();
	//cv::VideoWriter wr("./out6.avi", cv::VideoWriter::fourcc('D', 'I', 'V', 'X'), 25, frame.size(), true);

	while (true)
	{
		frame = m_videostream->read_one_frame();

		if (frame.empty())
			break;

		//wr << frame;

		mt_tracker->update(frame);
		update_face_info(frame);

		//render result	
		cv::Mat data_image = m_render->render(frame, convert_tracker_to_render(), m_statistics->get_totoalinfo(), mParams.render_params.draw_rect);

		cv::imshow("Video", data_image);

		char key = cv::waitKey(1);
		if (key == 27)
			break;
	}
}

void Multi_Thread_Dispatcher::init_modules()
{
	Dispatcher::init_modules();

	mt_tracker = std::make_unique<Multi_Thread_Tracker>(m_detector, m_tracker);
}